//
// Created by bleedingfight on 2020/7/5.
//
#include "isIsomorphic.h"
<<<<<<< HEAD:cxx/algorithm/src/isIsomorphic.cc
std::string map2str(std::string& s){
    int length = s.size();
    std::string result;
    std::map<char,int>chars;
    for(int ch_index = 0;ch_index<length;ch_index++){
        if(!chars.count(s.at(ch_index))){
            result+=char(ch_index);
            chars[s.at(ch_index)] = ch_index;
        } else
            result+=char(chars[s.at(ch_index)]);
    }
    return result;
}

bool isIsomorphic(std::string s, std::string t){
    return map2str(s) == map2str(t);
=======
std::string map2str(std::string& s) {
  int length = s.size();
  std::string result;
  std::map<char, int> chars;
  for (int ch_index = 0; ch_index < length; ch_index++) {
    if (!chars.count(s.at(ch_index))) {
      result += char(ch_index);
      chars[s.at(ch_index)] = ch_index;
    } else
      result += char(chars[s.at(ch_index)]);
  }
  return result;
}

bool isIsomorphic(std::string s, std::string t) {
  return map2str(s) == map2str(t);
>>>>>>> dev:cxx/algorithm/common/src/isIsomorphic.cc
}